package com.jlect.swebing.renderers.gwt.client;

import com.google.gwt.user.client.ui.AbsolutePanel;
import com.google.gwt.user.client.ui.RootPanel;
import com.google.gwt.user.client.ui.Widget;
import com.jlect.swebing.renderers.client.ContainerRenderer;
import com.jlect.swebing.renderers.client.RootPanelRenderer;

/**
 * Root panel renderer GWT implementation
 * @author Sergey Kozmin
 * @since 11.11.2007 20:56:52
 */
public class RootPanelRendererGWTImpl extends ContainerRendererGWTImpl implements RootPanelRenderer {
    private String slot;

    public ContainerRenderer getRootPanel() {
        return this;
    }

    public ContainerRenderer getRootPanel(String id) {
        slot = id;
        return this;
    }

    protected Widget provideWidget() {
        RootPanel rootPanel = slot != null ? RootPanel.get(slot) : RootPanel.get();
        AbsolutePanel panel = new AbsolutePanel();
        CompositeAttachEventProvider composite = new CompositeAttachEventProvider(panel);
        rootPanel.add(composite);
        return composite;
    }
}
